home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / Genie / Projects / A-line / Scripts / ABuild next >
Encoding:
Text File  |  2000-06-24  |  4.9 KB  |  204 lines

  1. # ABuild
  2. #
  3. Set MB-WEBPAGE "<http://www.metamage.com/proj/aline.html>"
  4. Set MB-SERIAL "2000031701"
  5. Set MB-COMPAT "1999111101"
  6. #
  7. # Synopsis:
  8. #    ABuild <target>
  9. #        [ --dist ]
  10. #        [ --depend ]
  11. #        [ --check | --commands | --make ]
  12. #        [ --arch 68K | PPC | Fat ]
  13. #        [ --build Debug | Release | all ]
  14. #
  15. # Options:
  16. #    --make        # Run dmake for this target and run the commands it outputs.
  17. #    --dist        # Take a snapshot (immediately).  Assumes you use my system.
  18. #    --depend    # Run MakeDepend to generate dependencies.  Requires Perl.
  19. #    --arch        # Specify which architecture to build for.  No PPC support yet.
  20. #    --build        # Specify which build type.
  21. #    --nested    # Used internally.  Basically, it suppresses output redirection.
  22. #
  23. # The options --dist and --depend are for maintainer use and may not run on
  24. # your system.  Both require Perl.  Use --depend if you change the dependencies
  25. # of the project (e.g. add files).  You shouldn't have any need of --dist, but
  26. # if you try it, be aware that it indirectly uses hardcoded pathnames, assumes your
  27. # date format is yyyy.mm.dd, and generally makes unwarranted assumptions.
  28. #
  29. # You should probably do --distclean before --dist unless you want that stuff in 
  30. # the snapshot.  You can also do --make on the same command line to recreate the 
  31. # stuff you just blasted with --distclean, but the order is important!
  32.  
  33.  
  34. # Start the timer
  35. Set TIME0 `date -n`
  36.  
  37. # Make sure we have what to build
  38. If {#} < 1
  39.     # We can change this later.  Maybe add a dialog box to pick one.
  40.     Echo "{0}: You must specify a target project to build."
  41.     Exit
  42. End
  43.  
  44. # Set some variables
  45. Execute "ALDirMacros"
  46. set NAME "{1}"
  47. set TARG "{TARGS}{1}:"
  48. set PROFILE "{TARG}{MANIFEST}:Profile.mpwsh"
  49. shift
  50.  
  51. # Defaults
  52. Set ARCH "--default"
  53. Set BUILD "--default"
  54. Set MAKEFILE "{SCRIPTS}Master.mk"
  55.  
  56. # Make sure the target directory (the Source folder) and the Build script exist.
  57. If "`Exists -d "{TARG}"`" == ""
  58.     Echo "{0}: Target '{TARG}' does not exist."
  59.     Exit 1
  60. Else if "`Exists -f "{PROFILE}"`" == ""
  61.     #echo "{0}: Build profile '{PROFILE}' does not exist."
  62.     #exit 1
  63. End
  64.  
  65. # Parse the command line.
  66. Loop
  67.     Break If {#} == 0
  68.     If "{1}" == "--dist"
  69.         Echo "Taking a snapshot of {NAME}."
  70.         SnapShot --verbose "{TARG}:"
  71.         shift
  72.     else if "{1}" == "--depend"
  73.         Set MAKEDEPEND " --depend"
  74.         shift
  75.     else if "{1}" == "--arch"
  76.         set ARCH "{2}"
  77.         Shift; Shift
  78.     else if "{1}" == "--build"
  79.         Set BUILD "{2}"
  80.         Shift; Shift
  81.     else if "{1}" == "--nested"
  82.         set NESTED yup
  83.         shift
  84.     else if "{1}" == "--make"
  85.         set ACTION make
  86.         shift
  87.     else
  88.         echo "{0}: Error: Unknown thing '{1}' on the command line."
  89.         exit 1
  90.     end
  91. end
  92.  
  93. If !"{ACTION}" && !"{MAKEDEPEND}"
  94.     Exit
  95. End
  96.  
  97.  
  98. # Open a new window to scribble in.
  99. if "{NESTED}" == ""
  100.     set OUT "{MPW}Build output"
  101.     begin
  102.         echo "• A-line •"
  103.         echo ""
  104.         echo "By Joshua Juran"
  105.         echo ""
  106.     end > "{OUT}"
  107.     Open "{OUT}"
  108. else
  109.     set OUT "Dev:stdout"
  110. end
  111.  
  112.  
  113. begin
  114.     
  115.     # Save the current default directory and call the Build script.
  116.     Set SAVEDIR "`Directory`"
  117.     Directory "{TARG}"
  118.     
  119.     If "`exists -f "{PROFILE}"`"
  120.         Execute "{PROFILE}"
  121.         If "{DESC}" != ""
  122.             Set COMMASPACE ", "
  123.         End
  124.         If "{MB-NEEDED}" > "{MB-SERIAL}"
  125.             Echo "Sorry, A-line {MB-SERIAL} is insufficient to build {NAME}."
  126.             Echo "Please get {MB-NEEDED} or later from {MB-WEBPAGE}."
  127.             Exit 1
  128.         End
  129.         If "{MB-AWARE}" < "{MB-COMPAT}"
  130.             Echo "Sorry, {NAME} is incompatible with A-line {MB-SERIAL}."
  131.             Echo "(It's only aware of A-line {MB-AWARE}.)"
  132.             Echo "Please upgrade it to a version that supports {MB-COMPAT}.  {PROJ-WEBPAGE}"
  133.             Exit 1
  134.         End
  135.     End
  136.     
  137.     # Mainly something to click on and hit Enter to rebuild
  138.     echo "Building {NAME}"
  139.     begin
  140.         set SAVEEXIT {Exit}
  141.         set Exit 0
  142.         echo `echo "Building {NAME}" | sed "s/./=/g"`
  143.         set Exit {SAVEEXIT}
  144.     end ≥ Dev:null
  145.     echo ""
  146.     echo -n "({0} {NAME} --{ACTION}{SKIP}"
  147.     If "{ARCH}"
  148.         Echo -n " --arch {ARCH}"
  149.     End
  150.     If "{BUILD}"
  151.         Echo -n " --build {BUILD}"
  152.     End
  153.     Echo ")"
  154.     Echo ""
  155.     
  156. #    If !`Exists "{TARG}{PREGEN}:Sources.mk"`
  157. #        MakeSource
  158. #    End
  159. #    If !`Exists "{TARG}{PREGEN}:Imports.mk"`
  160. #        MakeImports
  161. #    End
  162. #    Set DEPFILE "{TARG}{PREGEN}:Dependencies.mk"
  163. #    If "{MAKEDEPEND}" || !`Exists "{DEPFILE}"`
  164. #        Echo "Examining dependencies of {NAME}."
  165. #set DEPSTART `date -n`
  166. #        MakeDepend
  167. #set DEPEND `date -n`
  168. #Echo "Analyzing dependencies took `Evaluate {DEPEND} - {DEPSTART}` seconds."
  169. #    End
  170.     
  171.     If "{BUILD}" == "all"
  172.         Echo "Building all build types."
  173.         Echo ""
  174.         "{0}" "{NAME}" --nested --{ACTION} --arch {ARCH} --build Debug
  175.         "{0}" "{NAME}" --nested --{ACTION} --arch {ARCH} --build Release
  176.         Echo "Multi-build complete."
  177.         Exit
  178.     End
  179.     
  180.     set TIME1 `date -n`
  181.     set TIME2 {TIME1}
  182.     If "{PREBUILD}" != ""
  183.         for DEP in {PREBUILD}    # No quotes
  184.             Echo "{NAME} depends on {DEP}.  Building that first."
  185.             Echo ""
  186.             "{0}" "{DEP}" --nested --make --arch {ARCH} --build {BUILD}
  187.         end
  188.         echo "All prerequisite projects built.  Proceeding with {NAME}."
  189.         echo ""
  190.         set TIME2 `date -n`
  191.     End
  192.     
  193.     AMake --arch "{ARCH}" --build "{BUILD}"
  194.     
  195. end >> "{OUT}" ≥≥ "Dev:stdout"
  196.  
  197. # No quotes here!
  198. Directory {SAVEDIR}
  199. #PlaySound "Sosumi"
  200.  
  201.  
  202. Exit
  203. # The end.
  204.